home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 8_16BIT / PICSTART.ZIP / SAMPLE.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-01-07  |  2.2 KB  |  70 lines

  1. ;*******************************************************************
  2. ;                           SAMPLE.ASM
  3. ;                   8x8 Software Multiplier
  4. ;*******************************************************************
  5. ;
  6. ;   The 16 bit result is stored in 2 bytes
  7. ;
  8. ; Before calling the subroutine " mpy ", the multiplier should
  9. ; be loaded in location " mulplr ", and the multiplicand in
  10. ; " mulcnd " . The 16 bit result is stored in locations
  11. ; H_byte & L_byte.
  12. ;
  13. ;       Performance :
  14. ;                       Program Memory  :  15 locations
  15. ;                       # of cycles     :  71
  16. ;                       Scratch RAM     :   0 locations
  17. ;
  18. ;  This routine is optimized for code efficiency ( looped code )
  19. ;  For time efficiency code refer to "mult8x8F.asm" ( straight line code )
  20. ;*******************************************************************
  21. ;
  22. mulcnd  equ     09      ; 8 bit multiplicand
  23. mulplr  equ     10      ; 8 bit multiplier
  24. H_byte  equ     12      ; High byte of the 16 bit result
  25. L_byte  equ     13      ; Low byte of the 16 bit result
  26. count   equ     14      ; loop counter
  27. portb   equ     06      ; I/O register F6
  28. ;
  29. ;
  30.      include         "picreg.equ"
  31. ;
  32. ; *****************************         Begin Multiplier Routine
  33. mpy_S   clrf    H_byte
  34.         clrf    L_byte
  35.         movlw   8
  36.         movwf   count
  37.         movf    mulcnd,w
  38.         bcf     STATUS,CARRY    ; Clear the carry bit in the status Reg.
  39. loop    rrf     mulplr
  40.         btfsc   STATUS,CARRY
  41.         addwf   H_byte,Same
  42.         rrf     H_byte,Same
  43.         rrf     L_byte,Same
  44.         decfsz  count
  45.         goto    loop
  46. ;
  47.         retlw   0
  48. ;
  49. ;********************************************************************
  50. ;               Test Program
  51. ;*********************************************************************
  52. start   clrw
  53.         option
  54. main    movf    portb,w
  55.         movwf   mulplr          ; multiplier (in mulplr) = 05
  56.         movf    portb,w
  57.         movwf   mulcnd
  58. ;
  59. call_m  call    mpy_S           ; The result is in locations F12 & F13
  60.                                ; H_byte & L_byte
  61. ;
  62.         goto    main
  63. ;
  64.         org     01FFh
  65.         goto    start
  66. ;
  67.      END
  68.  
  69.  
  70.